package com.daka.tools;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.daka.entity.Dictionary;
import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.List;

public final class CodeMap
{
    /**
     * 用户注册时,可选的服务领域
     * @return
     */
    public static List<Dictionary> getUserServiceFiled()
    {
        List<Dictionary> list = new ArrayList<Dictionary>();
        list.add(new Dictionary("01", "扶贫济困"));
        list.add(new Dictionary("02", "助老助残"));
        list.add(new Dictionary("03", "社区服务"));
        list.add(new Dictionary("04", "生态建设"));
        list.add(new Dictionary("05", "大型活动"));
        list.add(new Dictionary("06", "抢险救灾"));
        list.add(new Dictionary("07", "网络文明"));
        list.add(new Dictionary("08", "社会管理"));
        list.add(new Dictionary("09", "文化建设"));
        list.add(new Dictionary("10", "西部开发"));
        list.add(new Dictionary("11", "海外服务"));
        list.add(new Dictionary("99", "其他"));
        return list;
    }
    public static String getUserServiceFiledValue(String param)
    {
        StringBuffer sb = new StringBuffer();
        String keys[] = param.split(";");
        if(null == keys || keys.length ==0)
            return sb.toString();
        for(Dictionary dic:getUserServiceFiled())
        {
            for(String key:keys)
            {
                if(key.trim().equals(dic.getCode().trim()))
                {
                    sb.append(dic.getName());
                    sb.append(";");
                }
            }
        }
        return sb.toString().substring(0,sb.toString().length()-1);
    }

    /**
     * 职业分类
     * @return
     */
    public static List<Dictionary> getJob()
    {
        List<Dictionary> list = new ArrayList<Dictionary>();
        list.add(new Dictionary("01", "互联网·游戏·软件"));
        list.add(new Dictionary("02", "电子·通信·硬件"));
        list.add(new Dictionary("03", "房地产·建筑·物业"));
        list.add(new Dictionary("04", "金融"));
        list.add(new Dictionary("05", "消费品"));
        list.add(new Dictionary("06", "汽车·机械·制造"));
        list.add(new Dictionary("07", "服务·外包·中介"));
        list.add(new Dictionary("08", "广告·传媒·教育·文化"));
        list.add(new Dictionary("09", "交通·贸易·物流"));
        list.add(new Dictionary("10", "制药·医疗"));
        list.add(new Dictionary("11", "能源·化工·环保"));
        list.add(new Dictionary("12", "政府·农林牧渔"));
        list.add(new Dictionary("99", "其他"));
        return list;
    }

    public static String getJobValue(String param)
    {
        StringBuffer sb = new StringBuffer();
        String keys[] = param.split(";");
        if(null == keys || keys.length ==0)
            return sb.toString();
        for(Dictionary dic:getJob())
        {
            for(String key:keys)
            {
                if(key.trim().equals(dic.getCode().trim()))
                {
                    sb.append(dic.getName());
                    sb.append(";");
                }
            }
        }
        return sb.toString().substring(0,sb.toString().length()-1);
    }
    /**
     * 用户注册时,可选的专业技能
     * @return
     */
    public static List<Dictionary> getUserSkill()
    {
        List<Dictionary> list = new ArrayList<Dictionary>();
        list.add(new Dictionary("01", "法律咨询"));
        list.add(new Dictionary("02", "维权服务"));
        list.add(new Dictionary("03", "心理健康"));
        list.add(new Dictionary("04", "敬老助老"));
        list.add(new Dictionary("05", "文化娱乐"));
        list.add(new Dictionary("06", "全民健身"));
        list.add(new Dictionary("07", "治安巡逻"));
        list.add(new Dictionary("08", "环保绿化"));
        list.add(new Dictionary("09", "卫生保洁"));
        list.add(new Dictionary("10", "教育培训"));
        list.add(new Dictionary("11", "纠纷调解"));
        list.add(new Dictionary("12", "减灾救灾"));
        list.add(new Dictionary("13", "扶贫济困"));
        list.add(new Dictionary("14", "科技创新"));
        list.add(new Dictionary("15", "医疗保健"));
        list.add(new Dictionary("16", "其他"));
        list.add(new Dictionary("51", "网络文明"));
        list.add(new Dictionary("53", "阳光助残"));
        list.add(new Dictionary("54", "应急救援"));
        list.add(new Dictionary("55", "邻里守望"));
        list.add(new Dictionary("56", "关爱农民工子女"));
        list.add(new Dictionary("99", "春运服务"));

        return list;
    }

    public static String getUserSkillValue(String param)
    {
        if(null == param || param.length() == 0){
            return "其他";
        }

        String keys[] = param.split(";");
        if(keys.length == 0){
            return null;
        }

        StringBuilder sb = new StringBuilder();
        for(Dictionary dic:getUserSkill())
        {
            for(String key:keys)
            {
                if(key.trim().equals(dic.getCode().trim()))
                {
                    sb.append(dic.getName());
                    sb.append(";");
                }
            }
        }
        if(sb.length() > 0){
            return sb.toString().substring(0,sb.toString().length()-1);
        }else{
            return "其他";
        }

    }
}
